package com.dacd.soundanalysis.sharepreferences

import android.content.Context
import android.content.SharedPreferences

class SharePreHelper {

    companion object {
        /*
        * 存储SharePreferences int
        */
        fun setSP(context: Context, key: String, value: Int) {
            val sp: SharedPreferences = context.getSharedPreferences(
                ShareConstants.DATA_SP, Context.MODE_PRIVATE
            )
            val editor: SharedPreferences.Editor = sp.edit()
            editor.putInt(key, value)
            editor.apply()
        }

        /**
         * 获取存储的SharePreferences String类型
         */
        fun getSPInt(context: Context, key: String): Int? {
            val sp: SharedPreferences = context.getSharedPreferences(
                ShareConstants.DATA_SP, Context.MODE_PRIVATE
            )
            return sp.getInt(key, -1)
        }
    }

}